package com.ktjy.controller;


import com.ktjy.pojo.SysRole;
import com.ktjy.service.SysRoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/admin/role")
public class SysRoleController {
    Logger log= LoggerFactory.getLogger(SysRoleController.class);

    @Autowired
    SysRoleService sysRoleService;

    @RequestMapping("/list")
    public Map<String,Object> list(){
        Map<String,Object> map=new HashMap<>();
        try {
            //查询数据
            List<SysRole> roleList = sysRoleService.findAll();
            //响应数据给页面
            map.put("code",1);
            map.put("msg","查询角色信息成功");
            map.put("data",roleList);
        } catch (Exception e) {
            log.error("SysRoleController中list方法执行报错的。",e);
            map.put("code",0);
            map.put("msg","查询角色信息失败");
        }
        return map;
    }
}
